import { createAPI } from '@/api/http';
import { Opts } from '@/api/opts';

/**
 *  @description 添加菜单
 *  @name createMenu
 *  @param  parentId 上级菜单 {string} 
 *  @param  name 菜单名 {string} 必传参数
 *  @param  path 跳转路由 {string} 必传参数
 *  @param  component 组件名 {string} 必传参数
 *  @param  mode 菜单类型 A：目录 B：菜单 C：按钮 {string} 必传参数
 *  @param  sort 排序 {number} 必传参数
 *  @param  icon 图标 {string} 
 *  @param  disabled 是否禁用 {boolean} 
 *  @param  hideTab 不要在tab中显示 {boolean} 
 *  @param  affix 是否固定在tab上 {boolean} 
 *  @param  memo 备注 {string} 

 *  @example 示例1
 *   onMounted(async () => {
 *     const { data } = await createUser({ data: { id: '1' } });
 *   });
 *  @example 示例2
 *  createUser({ data: { id: '1' } }).then(res => {});
 *  @example 示例3
 *  const { data } = await deleteUser({ params: { id: '1' } })
 */
export const createMenu = (opts: Opts) =>
  createAPI({
    method: 'post',
    url: '/wit/menu/createMenu',
    opts,
  });

/**
 *  @description 删除菜单
 *  @name deleteMenu
 *  @param  id menu id {string} 必传参数

 *  @example 示例1
 *   onMounted(async () => {
 *     const { data } = await createUser({ data: { id: '1' } });
 *   });
 *  @example 示例2
 *  createUser({ data: { id: '1' } }).then(res => {});
 *  @example 示例3
 *  const { data } = await deleteUser({ params: { id: '1' } })
 */
export const deleteMenu = (opts: Opts) =>
  createAPI({
    method: 'delete',
    url: '/wit/menu/deleteMenu',
    opts,
  });

/**
 *  @description 通过id获取菜单信息
 *  @name getMenuById
 *  @param  id menu id {string} 必传参数

 *  @example 示例1
 *   onMounted(async () => {
 *     const { data } = await createUser({ data: { id: '1' } });
 *   });
 *  @example 示例2
 *  createUser({ data: { id: '1' } }).then(res => {});
 *  @example 示例3
 *  const { data } = await deleteUser({ params: { id: '1' } })
 */
export const getMenuById = (opts: Opts) =>
  createAPI({
    method: 'get',
    url: '/wit/menu/getMenuById',
    opts,
  });

/**
 *  @description 获取菜单信息
 *  @name getMenuList
 *  @param  pageNum 页码 {integer} 
 *  @param  pageSize 每页数 {integer} 
 *  @param  name 菜单名 {string} 
 *  @param  path 路由 {string} 
 *  @param  component 组件名 {string} 

 *  @example 示例1
 *   onMounted(async () => {
 *     const { data } = await createUser({ data: { id: '1' } });
 *   });
 *  @example 示例2
 *  createUser({ data: { id: '1' } }).then(res => {});
 *  @example 示例3
 *  const { data } = await deleteUser({ params: { id: '1' } })
 */
export const getMenuList = (opts: Opts) =>
  createAPI({
    method: 'get',
    url: '/wit/menu/getMenuList',
    opts,
  });

/**
 *  @description 获取菜单树
 *  @name getTreeList
 *  @param  pageNum 页码 {integer} 
 *  @param  pageSize 每页数 {integer} 
 *  @param  name 菜单名 {string} 
 *  @param  path 路由 {string} 
 *  @param  component 组件名 {string} 

 *  @example 示例1
 *   onMounted(async () => {
 *     const { data } = await createUser({ data: { id: '1' } });
 *   });
 *  @example 示例2
 *  createUser({ data: { id: '1' } }).then(res => {});
 *  @example 示例3
 *  const { data } = await deleteUser({ params: { id: '1' } })
 */
export const getTreeList = (opts: Opts) =>
  createAPI({
    method: 'get',
    url: '/wit/menu/getTreeList',
    opts,
  });

/**
 *  @description 修改菜单
 *  @name updateMenu
 *  @param  id ID {string} 必传参数
 *  @param  parentId 上级菜单 {string} 
 *  @param  name 菜单名 {string} 
 *  @param  path 跳转路由 {string} 
 *  @param  component 组件名 {string} 
 *  @param  sort 排序 {number} 
 *  @param  icon 图标 {string} 
 *  @param  mode 菜单类型 A：目录 B：菜单 C：按钮 {string} 
 *  @param  disabled 是否禁用 {boolean} 
 *  @param  hideTab 不要在tab中显示 {boolean} 
 *  @param  affix 是否固定在tab上 {boolean} 
 *  @param  memo 备注 {string} 

 *  @example 示例1
 *   onMounted(async () => {
 *     const { data } = await createUser({ data: { id: '1' } });
 *   });
 *  @example 示例2
 *  createUser({ data: { id: '1' } }).then(res => {});
 *  @example 示例3
 *  const { data } = await deleteUser({ params: { id: '1' } })
 */
export const updateMenu = (opts: Opts) =>
  createAPI({
    method: 'put',
    url: '/wit/menu/updateMenu',
    opts,
  });
